package MOLE;

/** 
 JS ��ժҪ˵����
*/
public class JS
{

	public String JsCon = "";
	public JS()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}


	public final void Alert(String msg)
	{
		JsCon += "  alert('" + msg + "');";
	}

	public final void OpenWin(String url, String winname, int width, int height)
	{
		JsCon += " MOLEI.COMM.OpenWin( '" + url + "', '" + winname + "', " + width + ", " + height + ") ;  ";
	}


	public final void OpenWin(String url, String winname, int width, int height, int Isboxtype)
	{
		JsCon += " MOLEI.COMM.OpenWin( '" + url + "', '" + winname + "', " + width + ", " + height + ",0) ;  ";
	}

	public final void OpenWin(String url, String winname)
	{
		JsCon += " MOLEI.COMM.OpenWin( '" + url + "', '" + winname + "', 300, 150) ;  ";
	}

	public final void ResizeWin(Object width, Object height)
	{

		JsCon += " MOLEI.COMM.ResizeWin( " + Integer.parseInt(width.toString()) + "," + Integer.parseInt(height.toString()) + " ); ";
	}

	public final void AutoIfrm(String ifrmId)
	{
		JsCon += "MOLEI.COMM.AutoFrm(\"" + ifrmId + "\");";
	}
	public final void ResizeDiv(Object width, Object height)
	{
		String s = " new parent.NLOpen().Resize(" + width + "," + height + ");";

		JsCon += s;
	}

	public final void CloseWin()
	{
		JsCon += "window.opener=null;window.close();";
	}

	public final void Run()
	{
		MOLE.comm.RunJS(JsCon);
	}

	public final void Run(int Isdefer)
	{
		if (Isdefer == 1)
		{
			String s = "<script language='javascript' defer>" + JsCon + "</script>";
			System.Web.HttpContext.Current.Response.Write(s);
		}
	}

	public final void Goto(String url)
	{
		JsCon += " location='" + url + "' ; ";
	}
	public final void Confirm(String str, String trueStr, String fasleStr)
	{
		 JsCon += "if(   confirm('" + str + "')  ) {" + trueStr + "}else {" + fasleStr + "} ; ";
	}

	public final void Function(String funName, String funCon)
	{
		JsCon += " function " + funName + "() {" + funCon + "} ";
	}


	public static void Load(String jsPath, int IsDefer)
	{
		if (IsDefer == 0)
		{
			System.Web.HttpContext.Current.Response.Write("<Script src=\"" + jsPath + "\"> </script>");
		}
		else
		{
			System.Web.HttpContext.Current.Response.Write("<Script src=\"" + jsPath + "\" defer> </script>");
		}
	}

}